<template>
  <div class="report">
    <div class="head">
      <i class="iconfont head-icon" @click="comeback">&#xe689;</i>
      举报
    </div>
    <div class="report-text">
      <textarea v-model="reportText" placeholder="请输入举报原因"/>
      <button @click="report">举报</button>

    </div>
    <div class="report-foot"></div>
  </div>
</template>

<script>
import './index.scss';
import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
  export default {
    data () {
      return {
        reportText: '',
        userId: '',
        event_id: ''
      }
    },
    mounted () {
      this.userId = window.sessionStorage.getItem("userId")
      this.event_id = window.sessionStorage.getItem('event_id')
    },
    methods: {
      comeback () {
        window.history.go(-1)
      },
      report () {
        if (this.reportText == '') {
          alert('请输入举报的内容！')
        } else {
          http.post(CONSTANT.COMPLAINT, {event_id: this.event_id, userId: this.userId, content: this.reportText}, (res) => {
            console.log(res)
            if (res.code == 200 && res.errmsg == '保存成功') {
              alert('提交成功')
              window.history.go(-1)
            } else {
              console.log('出错了')
            }
          })
        }
      }
    }
  }
</script>
